package mock.servicesdirectory.dao.daointerface;


import java.util.ArrayList;
import java.util.List;

import mock.servicesdirectory.web.model.Geography;


public class GeographyDAO
{
    private static List<Geography> custLst=new ArrayList<Geography>();
    static int total=50;
    static {
        for(int i=1;i<total;i++)
        {
            custLst.add(new Geography("name "+i,i,"description "+i, "region "+i,"Yes"));
        }
    }
    public static Integer nextId()
    {
        return total++;
    }
    public static List<Geography> buildList()
    {
        
        return custLst;
    }
    public static int count()
    {
        return custLst.size();
    }
    public static List<Geography> find(int o,int q)
    {
        return custLst.subList(o, q);
    }
    public static void save(Geography c)
    {
        custLst.add(c);
    }
    public static Geography findById(Integer id)
    {
        for(Geography c:custLst)
        {
            if(c.getId()==id)
            {
                return c;
            }
        }
        return null;
    }
    public static void update(Geography c)
    {
        for(Geography x:custLst)
        {
            if(x.getId()==c.getId())
            {
                x.setName(c.getName());
            }
        }
    }
    public static void delete(Geography c)
    {
        custLst.remove(c);       
    }
    public static List<Geography> findNotById(int id, int from,int to)
    {
        List<Geography> subLst=custLst.subList(from, to);
        List<Geography> temp=new ArrayList<Geography>();

        for(Geography c:subLst)
        {
            if(c.getId()!=id)
            {
                temp.add(c);
            }
        }
        return temp;
    }
    public static List<Geography> findLesserAsId(int id, int from,int to)
    {
        List<Geography> subLst=custLst.subList(from, to);
        List<Geography> temp=new ArrayList<Geography>();

        for(Geography c:subLst)
        {
            if(c.getId()<=id)
            {
                temp.add(c);
            }
        }
        return temp;
    }
    public static List<Geography> findGreaterAsId(int id, int from,int to)
    {
        List<Geography> subLst=custLst.subList(from, to);
        List<Geography> temp=new ArrayList<Geography>();

        for(Geography c:subLst)
        {
            if(c.getId()>=id)
            {
                temp.add(c);
            }
        }
        return temp;
    }
}
